<?
$GLOBALS["VUE"]["includes"][]="includes/jquery-ui-1.7.2.wgm_admin.css";
$GLOBALS["VUE"]["includes"][]="includes/farbtastic/farbtastic.css";
$GLOBALS["VUE"]["includes"][]="includes/farbtastic/farbtastic.js";

$errors=array();
function show_error($place){
	global $errors;
	if(isset($errors[$place])){ ?>
		<div class="ui-state-error ui-corner-all" style="padding: 3px; margin: 5px;"> 
			<p>
				<span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
				<? echo $errors[$place]; ?>
			</p>
		</div>
	<? }
}

if(isset($_REQUEST["confmodule"])){
	if(!user_droit("admin-".$_REQUEST["confmodule"])) header("Location: ".CFG_REP_INSTALL."admin");
	
	// librairies
	if(is_dir("modules/".$_REQUEST["confmodule"]."/library")){
		$handle=opendir("modules/".$_REQUEST["confmodule"]."/library");
		while(false!==($file=readdir($handle))){
			if(strpos($file,"lib")!==false) require_once("modules/".$_REQUEST["confmodule"]."/library/".$file);
		}
	}

	// chargement core
	if(is_dir("modules/".$_REQUEST["confmodule"]."/classes")){
		$handle=opendir("modules/".$_REQUEST["confmodule"]."/classes");
		while(false!==($file=readdir($handle))){
			if(strpos($file,"class")!==false) require_once("modules/".$_REQUEST["confmodule"]."/classes/".$file);
		}
	}

	$GLOBALS["VUE"]["vue"]="modules/".$_REQUEST["confmodule"]."/admin/view.phtml";
	if(file_exists("modules/".$_REQUEST["confmodule"]."/admin/script.js")) $GLOBALS["VUE"]["includes"][]="modules/".$_REQUEST["confmodule"]."/admin/script.js";
	if(file_exists("modules/".$_REQUEST["confmodule"]."/admin/style.css")) $GLOBALS["VUE"]["includes"][]="modules/".$_REQUEST["confmodule"]."/admin/style.css";
	if(file_exists("modules/".$_REQUEST["confmodule"]."/admin/main.php")) include "modules/".$_REQUEST["confmodule"]."/admin/main.php";
	//$page=$_REQUEST["confmodule"];
}


$MENU="";
$res=$sql->request("select * from ".CFG_MYSQL_PREFIX."module where actif=1 and menuAdmin=1 order by nomComplet");
foreach($res as $var){
	if(isset($_REQUEST["confmodule"])&&($_REQUEST["confmodule"]==$var->nom)) $state="active";
	else $state="default";
	if(user_droit("admin-".$var->nom)) $MENU.="<a id='menu_".$var->nom."' href='".CFG_REP_INSTALL."admin?confmodule=".$var->nom."'><span class='ui-state-".$state." ui-corner-all ui-tabs pointer'>".$var->nomComplet."</span></a>\n";
}
if(user_droit("admin-configuration")){
	if($GLOBALS["VUE"]["page"]=="configuration") $MENU.="<a href='".CFG_REP_INSTALL."admin/configuration'><span class='ui-state-active ui-corner-all ui-tabs pointer'>Configuration</span></a>\n";
	else $MENU.="<a href='".CFG_REP_INSTALL."admin/configuration'><span class='ui-state-default ui-corner-all ui-tabs pointer'>Configuration</span></a>\n";
}
$MENU.="<a href='".CFG_REP_INSTALL."'><span class='ui-state-default ui-corner-all ui-tabs pointer'>Retour au site</span></a>\n";



?>
